﻿#region Usings

using System.Data.Entity.ModelConfiguration;
using Rail.Net.Core.Model;

#endregion

namespace Rail.Net.Data.Configuration
{
    public class DistanceMap : EntityTypeConfiguration<Distance>
    {
        public DistanceMap()
        {
            ToTable("Distances");
            HasKey(distance => distance.Id);

            Property(distance => distance.TispTisp).IsRequired().HasMaxLength(8);
            Property(distance => distance.Oebb).IsRequired();
            Property(distance => distance.Db).IsRequired();
            Property(distance => distance.Sbb).IsRequired();
            Property(distance => distance.P10).IsRequired();
            Property(distance => distance.P20).IsRequired();
            Property(distance => distance.P30).IsRequired();
            Property(distance => distance.P31).IsRequired();
            Property(distance => distance.P40).IsRequired();
            Property(distance => distance.P41).IsRequired();
            Property(distance => distance.P42).IsRequired();
            Property(distance => distance.P43).IsRequired();
            Property(distance => distance.P50).IsRequired();
            Property(distance => distance.P51).IsRequired();
            Property(distance => distance.P52).IsRequired();
            Property(distance => distance.P53).IsRequired();
            Property(distance => distance.P60).IsRequired();
            Property(distance => distance.P80).IsRequired();
            Property(distance => distance.P81).IsRequired();

            HasRequired(distance => distance.Station1).WithMany(station => station.Distances1);
            HasRequired(distance => distance.Station2).WithMany(station => station.Distances2);
        }
    }
}